﻿using System.Collections.Generic;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate;
using System.IO;

namespace ShevaEngine.Core.Modules.Materials
{
    /// <summary>
    /// Textures.
    /// </summary>
    public class Textures : SortedList<string, string>
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        public Textures()
            : base()
        {

        }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="textures"></param>
        public Textures(Dictionary<string, string> textures)
            : base(textures)
        {
            //foreach (KeyValuePair<string, string> item in textures)
            //    this.Add(item.Key, item.Value);
        }
    }


    /// <summary>
    /// Textures comparer.
    /// </summary>
    public class TexturesComparer : IComparer<Textures>
    {
        /// <summary>
        /// Method compares two Textures objects.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public int Compare(Textures x, Textures y)
        {
            for (int i = 0; i < x.Count; i++)
            {
                if (i >= y.Count)
                    return 1;

                int diff = string.Compare(x.Keys[i], y.Keys[i]);

                if (diff == 0)
                {
                    diff = string.Compare(x.Values[i], y.Values[i]);

                    if (diff != 0)
                        return diff;
                }
                else
                    return diff;
            }

            if (y.Count > x.Count)
                return -1;

            return 0;
        }
    }
}
